﻿using System;
using System.Collections.Generic;
using System.Text;

using ECCIT;
using OgilvyOne.UKNow.IDAL;
using OgilvyOne.UKNow.DALFactory;
using OgilvyOne.UKNow.Model;

namespace OgilvyOne.UKNow.BLL
{
    public class EventsVideoBLL
    {
        public int LanguageID { get; set; }
        public EventsVideoBLL(int langID)
        {
            this.LanguageID = langID;
        }

        public ResultInfo Save(EventsVideoModel info)
        {
            IDALEventsVideo use = EventsVideoDALFactory.Create(LanguageID);
            info.LanguageID = LanguageID;
            return use.Save(info);
        }
        //删除单个视频的数据
        public ResultInfo delVideo(int eid)
        {
            IList<int?> list = new List<int?>();
            list.Add(eid);
            IDALEventsVideo use = EventsVideoDALFactory.Create(LanguageID);
            return use.Delete(list);
        }
        public ResultInfo DeleteVideosByEventsID(int eventsID)
        {
            return EventsVideoDALFactory.Create(LanguageID).DeleteByEventsID(null, eventsID);
        }

        //根据视频id 获取该视频信息
        public EventsVideoModel selVideo(int id)
        {
            IDALEventsVideo use = EventsVideoDALFactory.Create(LanguageID);
            return use.GetEventsVideoModelByID(id);
        }
        /*修改人：穆凤凤
    * 修改时间：2012-01-02
    * 修改内容：
    *      添加方法,修改某个活动视频的发布状态
    *      有mff注释的为本次修改的代码
    */
        //mff
        //修个单个视频的发布状态
        public void modPubOne(int eid)
        {
            List<int?> list = new List<int?>();
            list.Add(eid);

            IDALEventsVideo use = EventsVideoDALFactory.Create(LanguageID);

            EventsVideoModel model = use.GetEventsVideoModelByID(eid); //查看该视频的当前发布状态
            if (model.State > 0) //该视频的当前为发布状态
            {
                use.UnPublish(list);
                //设置为该视频的state为0 不发布 (传递参数 eid 和 int=0)
            }
            else
            {
                use.Publish(list);
                //设置该视频的state为1 发布     (传递参数 eid 和 int=1)
            }
        }
        //mff
        public IList<EventsVideoModel> GetAllEventsVideoModels(int? eventsID)
        {
            IDALEventsVideo use = EventsVideoDALFactory.Create(LanguageID);
            return use.GetAllEventsVideoModels(eventsID);
        }
        public IList<EventsVideoModel> GetKeywordEventsVideoModels(string keyword)
        {
            IDALEventsVideo use = EventsVideoDALFactory.Create(LanguageID);
            return use.GetKeywordEventsVideoModels(keyword);
        }

        public IList<EventsVideoModel> GetPublishedEventsVideoModels(int? eventsID)
        {
            return EventsVideoDALFactory.Create(LanguageID).GetPublishedEventsVideoModels(eventsID);
        }
    }
}
